//
//  IWNewfeatureViewController.m
//  ItcastWeibo
//
//  Created by apple on 14-5-6.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "IWNewfeatureViewController.h"
#import "WYCLoginController.h"
#define IWNewfeatureImageCount 3

@interface IWNewfeatureViewController () <UIScrollViewDelegate>
{
    UIScrollView * scrollVc;
    UIImageView * imageView ;
    UIButton * btn;
    
    // 判断是否是第一次进入应用
    
    BOOL flag;
}

@property (nonatomic, weak) UIPageControl *pageControl;
@end

@implementation IWNewfeatureViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
     scrollVc = [[UIScrollView alloc]initWithFrame:self.view.frame];
    
    
    
    btn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth / 2 - 250 * px,ScreenHeight - 200 * px , 500 * px, 200 * px)];
//    [btn setTitle:@"立即体验" forState:UIControlStateNormal];
//    btn.backgroundColor = wycMain;
//    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(goClass) forControlEvents:UIControlEventTouchUpInside];
    
    
    for (int i=0; i<3; i++)
    {
        NSString * imageStr = [NSString stringWithFormat:@"pic_guidepage_%d",i+1];
        imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageStr]];
        imageView.frame = CGRectMake(self.view.frame.size.width*i,0,self.view.frame.size.width , self.view.frame.size.height);

        [scrollVc addSubview:imageView];
        
    }
    scrollVc.pagingEnabled = YES;
    scrollVc.contentSize = CGSizeMake(self.view.frame.size.width*3, CGRectGetHeight(scrollVc.frame));
    scrollVc.contentOffset = CGPointMake(0, 0);
    scrollVc.delegate = self;
    
    [self.view addSubview:scrollVc];
    [self.view  addSubview:btn];
    
}

-(void)goClass
{
    WYCLogFunc;
    flag = YES;
    
    NSUserDefaults *useDef = [NSUserDefaults standardUserDefaults];
    
    // 保存用户数据
    
    [useDef setBool:flag forKey:@"notFirst"];
    
    [useDef synchronize];
    
    
    WYCLoginController * VC =  [[WYCLoginController alloc] init];
    [self presentViewController:VC animated:YES completion:nil];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"%g",scrollVc.contentOffset.x);
    if (scrollVc.contentOffset.x >= self.view.frame.size.width * 2 )

    {
         btn.hidden = NO;
    }
    else
    {
        btn.hidden = YES;
    }

}
//导航栏（是否）隐藏:（是）
-(BOOL)prefersStatusBarHidden
{
    return YES;
}
@end
